﻿using UnityEngine;
using System.Collections;
using System;

public class Item{

    //public enum Type : int
    //{
    //    //0.武器类
    //    wuqi,
    //    //1.盔甲类
    //    kuijia,
    //    //2.手镯类
    //    shouzhuo,
    //    //3.水晶类
    //    shuijing,
    //    //4.礼盒类
    //    lihe
    //}
    //物品类型
    private string itemType;
    //物品名称
    private string name;
    //物品等级
    private int lv = 1;
    //物品的攻击力
    private int att = 0;
    //物品的防御力
    private int def = 0;
    //物品的生命值
    private int hp = 0;
    //物品的魔法值
    private int sp = 0;
    //物品的说明信息
    private string message;
    public Item() { }
    public Item(string t,string n,int l,int a,int d,int h,int s)
    {
        itemType = t;
        name = n;
        if (l > 0)
        {
            lv = l;
        }
        if (a >= 0)
        {
            att = a;
        }
        if (d >= 0)
        {
            def = d;
        }
        if (h >= 0)
        {
            hp = h;
        }
        if (s >= 0)
        {
            sp = s;
        }
    }

    public string ItemType
    {
        set { itemType = value; }
        get { return itemType; }
    }

    public string Name
    {
        set { name = value; }
        get { return name; }
    }

    public int Lv
    {
        set
        {
            if (value > 0)
            {
                lv = value;
            }
        }
        get { return lv; }
    }

    public int Att
    {
        set {
            if (value >= 0)
            {
                att = value;
            }
        }
        get { return att; }
    }

    public int Def
    {
        set
        {
            if (value >= 0)
            {
                def = value;
            }
        }
        get { return def; }
    }

    public int Hp
    {
        set
        {
            if (value >= 0)
            {
                hp = value;
            }
        }
        get { return hp; }
    }

    public int Sp
    {
        set
        {
            if (value >= 0)
            {
                sp = value;
            }
        }
        get { return sp; }
    }

    public string Message
    {
        set { message = value; }
        get { return message; }
    }
    //判断物品是装备还是消耗品
    public static int IsOneOf(string type)
    {
        int flag = 0;
        //0为装备，1为消耗品
        switch (type)
        {
            case "Wuqi": flag = 0; break;
            case "Kuijia": flag = 0; break;
            case "Shouzhuo": flag = 0; break;
            case "Shuijing": flag = 0; break;
            case "Lihe": flag = 1; break;
            default: Debug.Log("你是不是少写了什么东西？"); break;
        }
        return flag;
    }
 
}
